package one.stand.config;

import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

@Configuration
public class JdbcTemplateMyConfig {

    public DataSource getDateSource() {
        return DataSourceBuilder.create()
                .driverClassName("com.mysql.jdbc.Driver")
                .url("jdbc:mysql://139.224.46.153:3306/hmsc2?useUnicode=true&serverTimezone=GMT%2B8&characterEncoding=utf8")
                .username("jmp")
                .password("jmp@1232")
                .build();
    }

    /**
     * 商品导入
     */
    @Bean
    public JdbcTemplate myJdbcTemplate() {
        DataSource dataSource = getDateSource();
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
//        JdbcProperties.Template template = new JdbcProperties.Template();
//        jdbcTemplate.setFetchSize(template.getFetchSize());
//        jdbcTemplate.setMaxRows(template.getMaxRows());
//        if (template.getQueryTimeout() != null) {
//            jdbcTemplate
//                    .setQueryTimeout((int) template.getQueryTimeout().getSeconds());
//        }
        return jdbcTemplate;
    }
}
